<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {

	public $sidebar_view='';
	public $main_view='';
	public $top_view='';

	function __construct()
	{
		parent::__construct();

		$this->load->helper('url');
		$this->load->library('ion_auth');
		$this->load->database();

	}

	function index()
	{
		//$this->output->cache(6000);
		/*
			sidebar begin
		*/
		$query = $this->db->get('sidebar');
		$sidebar_result = $query->result();
		foreach($sidebar_result as $sidebar)
		{
			//$sidbar_value = $sidebar->name;
			$this->sidebar_view .= <<<sidebar_html
				<h1>{$sidebar->name}</h1>
				<ul>
sidebar_html;

		$sidebar_url_query = $this->db->select('name,url')->from('sidebar_url')->where('type',$sidebar->id)->order_by('order','desc')->get();

			foreach($sidebar_url_query->result() as $sidebar_url_array)
			{
				$this->sidebar_view .= <<<sidebar_url
				<li><a href="{$sidebar_url_array->url}">
				$sidebar_url_array->name
				</a></li>
sidebar_url;
			}
			$this->sidebar_view .= "</ul>";

		}
		/*
			sidebar end
		*/

		/*
			main begin
		*/

		$query = $this->db->get('main');
		$main_result = $query->result();

		$main_class = 'bgblue';
		foreach($main_result as $main)
		{
			$main_class = $main_class == 'bgblue'? 'bgyellow':'bgblue';;
			$this->main_view .= <<<main_html
				<div class="$main_class">
				<h1><a class="fbrown">{$main->name}</a></h1>
				<h2 class="aw">
main_html;

		$main_url_query = $this->db->select('name,url')->from('main_url')->where('type',$main->id)->order_by('order','desc')->get();

			foreach($main_url_query->result() as $main_url_array)
			{
				$this->main_view .= <<<main_url
				<a href="{$main_url_array->url}">
				$main_url_array->name
				</a>
main_url;
			}
			$this->main_view .= "</h2></div>";

		}
		/*
			main end
		*/

		/*
			top begin
		*/
		$query = $this->db->get('top');

		foreach($query->result() as $top)
		{

			$this->top_view .= '<li><a href="'.$top->url.'">'.$top->name.'</a></li>';
		}
		/*
			top end
		*/
/*
		$this->load->model('ion_auth_model');

		$login_info_val = $this->ion_auth_model->get_user_info();


		$login_info = <<<login_info
<h1>用户管理</h1>
<ul>
	$login_info_val
</ul>
login_info;
*/
		$data['sidebar_view'] = $this->sidebar_view;
		$data['main_view'] = $this->main_view;
		$data['top_view'] = $this->top_view;



		$this->load->view('index_view',$data);


	}



}

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */